package com.dao.impl;

import com.dao.MemberDao;
import com.entity.Member;
import com.mapper.MemberMapper;
import com.page.PageInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("memberDao")
public class MemberDaoImpl implements MemberDao {
    @Resource
    private MemberMapper memberMapper;

    @Override
    public List<Member> getAllMembers() { return memberMapper.selectByExample(null); }

    /**
     * @param pageInfo
     * @return
     */
    @Override

    public List<Member> getMemberByPage(PageInfo pageInfo) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("currPage",pageInfo.getCurrPage());
        map.put("pageSize",pageInfo.getPageSize());
        System.out.println("111");

        return memberMapper.getMemberByPage(map);
    }
    @Override
    public Integer deleteMemberById(Integer aId) {
        return memberMapper.deleteByPrimaryKey(aId);
    }

    @Override
    public Member getMemberByMnoWithMAR(String mno) {
        return memberMapper.getMemberByMnoWithMAR(mno);
    }

    @Override
    public Member getMemberByMnoWithMARAndAT(String mno) {
        return memberMapper.getMemberByMnoWithMARAndAT(mno);

    }
    @Override
    public Integer updateMememberTest(Member member) {
        return memberMapper.updateByPrimaryKeySelective(member);
    }
    @Override
    public Integer updateMember(Member member) {
        return memberMapper.updateByPrimaryKey(member);
    }
    @Override
    public Integer addMember(Member member) {
        return memberMapper.insertSelective(member);
    }

}

